<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/3/14 0014
 * Time: 19:07
 */

namespace App\Models\Admin;

use Illuminate\Database\Eloquent\Model;

class Category extends Model
{
    /*
        * @ 使用eloquent create方法能操作的 字段
        */
    protected $fillable = ['category_thumbnail','category_name','category_type','category_commit','category_status'];
    /**
     * 与模型关联的数据表
     */
    protected $table = 'y_categorys';
    /**
     * 与模型关联的数据表的主键
     */
    protected $primaryKey = 'category_id';

    public function categorysType(){
        return $this->belongsTo('App\Models\Admin\CategorysType', 'category_type', 'categorys_type_id');
    }

    /*
     * 一个修改器，修改picture_check字段的值
     */
    public function setCategoryStatusAttribute($value)
    {
        $this->attributes['category_status'] = $value;
    }
}